<!--验收页面-->
<template>
    <view class="body" style="width: 100%;overflow: auto;" id="zrAcceptanceInfo">
        <view class="u-page" style="width: 100%;background-color: #f7f8fa;margin-bottom: 10rpx;border-radius:6rpx;">
<!--                <jn-prj-detail :prj-id="prjDetail.prjId" :prj-type="prjType"></jn-prj-detail>
                <jn-site-detail v-if="[14].includes(prjDetail.pageType)" :prj-id="prjDetail.prjId" :prj-type="prjType"></jn-site-detail>
                <jn-exclusive-detail :prj-id="prjDetail.prjId" :prj-type="prjType"></jn-exclusive-detail>-->
                <prj-accept-info :prj-detail="prjDetail" v-if="isPrjAcceptInfo" :prj-type="prjType"></prj-accept-info>
                <material-service :prj-detail="prjDetail" :prj-type="prjType" v-if="prjDetail.manageMode!== '01' && prjType!== 'M'"></material-service>
                <supply-material-list v-if="showBtnConfig&&prjDetail.type!=='todo'" :prj-detail="prjDetail" :prj-type="prjType"></supply-material-list>
                <AttachMentInfo :attachMentObj="prjDetail"></AttachMentInfo>
                <jn-approval-detail :processInstID="processInstId" :prj-type="prjType"></jn-approval-detail>
        </view>
        <footer-btn :btn-list="btnList" @handleBtn="handleBtn" v-if="prjDetail.type==='todo'"></footer-btn>
        <view style="position: fixed;right: 0;top: 40rpx;background-color:#555555;text-align: center;padding: 0 20rpx" v-if="showPopMenu">
            <view style="position: absolute;right: 30rpx;top: -24rpx;width: 0;height: 0;border-left: 20rpx solid transparent;border-right: 20rpx solid transparent;border-bottom: 24rpx solid #555555;"></view>
            <view v-for="(item,index) in topBtnList" :key="index">
                <view style="height: 2rpx;background-color: #aaaaaa;cursor: pointer" v-if="index!==0"></view>
                <view style="height: 64rpx;line-height: 70rpx;color: #F2F2F2" @click="handleBtn(item.method)">{{item.label}}</view>
            </view>
        </view>
    </view>
</template>

<script>
import JnPrjDetail from "@/component/jn/JnPrjDetail.vue";
import JnSiteDetail from "@/component/jn/JnSiteDetail.vue";
import JnExclusiveDetail from "@/component/jn/JnExclusiveDetail.vue";
import JnApprovalDetail from "@/component/jn/JnApprovalDetail.vue";
import supplyMaterialList from "@/inspur/acceptance/components/supplyMaterialList.vue";
import prjAcceptInfo from "@/inspur/acceptance/components/prjAcceptInfo.vue";
import footerBtn from "@/component/basic/footerBtn.vue";
import AttachMentInfo from "@/inspur/attachmentinfo/index.vue";
import MaterialService from "@/inspur/acceptance/components/materialService.vue";

const optionBtnType = {
    F4: '资源录入',
    F5: '资源确认',
    F10: '验收申请',
    F11: '验收审核',
    F91: '初验申请',
    F92: '初验审核',
    F93: '终验申请',
    F94: '终验审核',
}
const topBtnList1=[
    {
        label:'乙供物资明细编制',
        method:'supplyEdit'
    },
    {
        label:'物资服务同步资源',
        method:'materialResource'
    },
    {
        label:'资源录入',
        method:'resourceInit'
    },
]
const topBtnList2=[
    {
        label:'乙供物资明细查看',
        method:'supplyCheck'
    },
    {
        label:'资源确认',
        method:'resourceConfirm'
    },
]
const topBtnList3=[
    {
        label:'乙供物资明细查看',
        method:'supplyCheck'
    }
]
export default {
    components: {
        MaterialService,
        supplyMaterialList,
        AttachMentInfo,
        JnPrjDetail,
        JnSiteDetail,
        JnExclusiveDetail,
        prjAcceptInfo,
        JnApprovalDetail,
        footerBtn
    },
    data() {
        return {
            prjDetail:{
            },
            processInstId:'',
            prjType:'M',
            fileObj:{},
            isPrjAcceptInfo:false,
            //1.['A', 'B', 'D', 'G', 'Z'], // A = 铁塔类项目, B = 室分类项目, C = 传输类项目, G = 微姑类项目, Z = 整体项目 ||
            // 2.M =信息化  本次重构只涉及信息化项目
            btnList:[
                {
                    label:'保存',
                    method:'save',
                },
                {
                    label:'回退',
                    method:'back',
                },
                {
                    label:'下一步',
                    method:'doNext',
                }
            ],
            topBtnList:[],
            showPopMenu:false,
            showBtnConfig:false,
        }
    },
    onLoad(option) {
        // this.prjDetail=option;
        uni.setStorageSync("sysToken", option.sysToken)
        this.prjDetail={
            ...option,
            prjStage:'F',
        }
        this.processInstId=option.processInstId;
        this.getProjectType();
        uni.setNavigationBarTitle({
            // title: optionBtnType[this.prjDetail.btnType] || '工程管理'
            title: '项目详情'
        });
    },
    onShow() {
        // 导航栏添加图标  只有综合查询的话不需要
        // const url = window.location.origin + window.location.pathname
        // let menus = [{
        //     ico: url + "static/imges/more.png",
        //     callback: () => this.showPop()
        // }];
        // if(this.prjDetail.pageType === '14' && this.prjDetail.btnType === 'F4' || ['13','11'].includes(this.prjDetail.pageType) && this.prjDetail.btnType === 'F91'){
        //     this.topBtnList=JSON.parse(JSON.stringify(topBtnList1))
        // }else if(this.prjDetail.pageType === '14' && this.prjDetail.btnType === 'F5' || ['13','11'].includes(this.prjDetail.pageType) && this.prjDetail.btnType === 'F92'){
        //     this.topBtnList=JSON.parse(JSON.stringify(topBtnList2))
        // }else{
        //     this.topBtnList=JSON.parse(JSON.stringify(topBtnList3))
        // }
        // if(['13','11','14'].includes(this.prjDetail.pageType) && this.prjDetail.type==='todo'){
        //     console.log('设置图标')
        //     imp.iWindow.setMenus(menus);
        // }
    },
    onHide() {
        console.log("执行onHide")
        // imp.iWindow.setMenus([{
        //     ico: '',
        //     callback: () => {
        //     }
        // }]);
    },
    mounted() {
        // 监听高度变化
        const div = document.querySelector('#zrAcceptanceInfo');
        const url=window.location.protocol+'//'+window.location.host;
        // 创建一个ResizeObserver实例，并提供一个回调函数
        const resizeObserver = new ResizeObserver(entries => {
            for (let entry of entries) {
                const { height } = entry.contentRect;
                console.log(height, '验收页面发送高度')
                window.parent.postMessage({ type: 'acceptanceHeight', height: height }, url)
            }
        });
        resizeObserver.observe(div)
    },
    methods:{
        getProjectType(){
          this.$axios.get('/settlement/api/adjustment/queryPrjInfo?prjId='+this.prjDetail.prjId).then((res)=>{
              this.prjType = res.data.prjType;
              let obj = res.data
              Object.assign(this.prjDetail,obj)
              // this.prjDetail.manageMode = res.data.manageMode;
              if(res.data.prjType === 'M'){
                  this.getProjectInfo();
                  this.getConfigButton();
              }else{
                  if(res.data.manageMode === '01'){
                      this.getConfigButton();
                  }else{
                      this.showBtnConfig=true;
                  }
                  this.$nextTick(() => {
                      this.isPrjAcceptInfo = true
                  })
              }
          })
        },
        getConfigButton(){
            this.$axios.post('/material/api/service/serviceDetailConfig/configButtonIsDisplayed?ifSingleProject=0&subPrjId=&prjId='+this.prjDetail.prjId).then((res)=>{
                this.showBtnConfig=res.data;
            })
        },
        getProjectInfo(){
            this.$axios.get('/acceptance/api/accept/itAcceptance/getInfoInItInfo?prjId='+this.prjDetail.prjId).then((res)=>{
                this.prjDetail.pageType = +res.data?.SECONDARYTYPE
                this.fileObj.prjType = res.data?.PRJTYPE
                this.fileObj.buildModes = res.data?.BUILDMODESb
                this.prjDetail.accType = +res.data?.ACCTYPE
                this.$nextTick(() => {
                    this.isPrjAcceptInfo = true
                })
            })
        },
        handleBtn(methodName) {
            this[methodName]()
        },
        // save(){
        //     console.log('保存')
        // },
        // back(){
        //     console.log('回退')
        // },
        // doNext(){
        //     console.log('下一步')
        // },
        //展示右上角弹窗
        // showPop(){
        //     this.showPopMenu = !this.showPopMenu;
        // },
        //乙供物资明细编制
        // supplyEdit(){
        //     console.log('乙供物资明细编制')
        //     uni.showModal({
        //         title: "温馨提示",
        //         content: `该功能暂不支持在app端进行操作，请在PMS我的待办中进行操作！`,
        //         showCancel: false,
        //         confirmColor: '#eb4b4b',
        //     });
        // },
        // //物资服务同步资源
        // materialResource(){
        //     console.log('调用实物信息同步资源接口推送资源，推送成功后弹出提示“数据同步资源成功。')
        // },
        // //资源录入
        // resourceInit(){
        //     console.log('资源录入')
        //     uni.showModal({
        //         title: "温馨提示",
        //         content: `有签有码物资请在工程管理APP-项目查询-资源录入模块进行录入操作，无需贴签物资请在PMS我的待办中进行资源录入操作！`,
        //         showCancel: false,
        //         confirmColor: '#eb4b4b',
        //     });
        // },
        // //资源确认
        // resourceConfirm(){
        //     console.log('资源确认')
        //     uni.showModal({
        //         title: "温馨提示",
        //         content: `有签有码物资请在工程管理APP-项目查询-资源确认模块进行确认操作，无需贴签物资请在PMS我的待办中进行资源确认操作！`,
        //         showCancel: false,
        //         confirmColor: '#eb4b4b',
        //     });
        // },
        //乙供物资明细查看
        supplyCheck(){
            uni.navigateTo({
                url:'/inspur/acceptance/supplyMaterialList',
            })
        }
    }
}
</script>

<style>@import "@/common/common-ui.css";</style>
<style scoped lang="scss">
.u-page {
    padding: 0;
}
</style>